home *** CD-ROM | disk | FTP | other *** search
/ Scene 96 / Scene 96 International Edition (Zyklop Software) (Disc 2) (1997).iso / misc / coding / midas060 / src / rawfile.h < prev    next >
Encoding:
C/C++ Source or Header  |  1997-01-16  |  7.6 KB  |  286 lines

  1. /*      RAWFILE.H
  2.  *
  3.  * Raw file I/O for MIDAS Sound System
  4.  *
  5.  * $Id: rawfile.h,v 1.3 1997/01/16 18:41:59 pekangas Exp $
  6.  *
  7.  * Copyright 1996,1997 Housemarque Inc.
  8.  *
  9.  * This file is part of the MIDAS Sound System, and may only be
  10.  * used, modified and distributed under the terms of the MIDAS
  11.  * Sound System license, LICENSE.TXT. By continuing to use,
  12.  * modify or distribute this file you indicate that you have
  13.  * read the license and understand and accept it fully.
  14. */
  15.  
  16.  
  17. #ifndef __RAWFILE_H
  18. #define __RAWFILE_H
  19.  
  20.  
  21.  
  22. #ifdef __WIN32__
  23.     #define rfFile_fileHandle U32 f;
  24. #else
  25.     #ifndef FILE
  26.     #include <stdio.h>
  27.     #endif
  28.     #define rfFile_fileHandle FILE *f;
  29. #endif
  30.  
  31.  
  32. /****************************************************************************\
  33. *       struct rfFile
  34. *       -------------
  35. * Description:  File state structure
  36. \****************************************************************************/
  37.  
  38. typedef struct
  39. {
  40.     rfFile_fileHandle
  41. } rfFile;
  42.  
  43.  
  44.  
  45.  
  46. /****************************************************************************\
  47. *       typedef rfHandle;
  48. *       -----------------
  49. * Description: Raw file I/O file handle
  50. \****************************************************************************/
  51.  
  52. typedef rfFile* rfHandle;
  53.  
  54.  
  55.  
  56. /****************************************************************************\
  57. *       enum rfOpenMode
  58. *       ---------------
  59. * Description:  File opening mode. Used by rfOpen()
  60. \****************************************************************************/
  61.  
  62. enum rfOpenMode
  63. {
  64.     rfOpenRead = 1,                     /* open file for reading */
  65.     rfOpenWrite = 2,                    /* open file for writing */
  66.     rfOpenReadWrite = 3                 /* open file for both reading and
  67.                                            writing */
  68. };
  69.  
  70.  
  71.  
  72. /****************************************************************************\
  73. *       enum rfSeekMode
  74. *       ---------------
  75. * Description:  File seeking mode. Used by rfSeek()
  76. \****************************************************************************/
  77.  
  78. enum rfSeekMode
  79. {
  80.     rfSeekAbsolute = 1,                 /* seek to an absolute position from
  81.                                            the beginning of the file */
  82.     rfSeekRelative = 2,                 /* seek to a position relative to
  83.                                            current position */
  84.     rfSeekEnd = 3                       /* relative to the end of file */
  85. };
  86.  
  87.  
  88.  
  89. #ifdef __cplusplus
  90. extern "C" {
  91. #endif
  92.  
  93.  
  94. /****************************************************************************\
  95. *
  96. * Function:     int rfOpen(char *fileName, int openMode, rfHandle *file);
  97. *
  98. * Description:  Opens a file for reading or writing
  99. *
  100. * Input:        char *fileName          name of file
  101. *               int openMode            file opening mode, see enum rfOpenMode
  102. *               rfHandle *file          pointer to file handle
  103. *
  104. * Returns:      MIDAS error code.
  105. *               File handle is stored in *file.
  106. *
  107. \****************************************************************************/
  108.  
  109. int CALLING rfOpen(char *fileName, int openMode, rfHandle *file);
  110.  
  111.  
  112.  
  113.  
  114. /****************************************************************************\
  115. *
  116. * Function:     int rfClose(rfHandle file);
  117. *
  118. * Description:  Closes a file opened with rfOpen().
  119. *
  120. * Input:        rfHandle file           handle of an open file
  121. *
  122. * Returns:      MIDAS error code
  123. *
  124. \****************************************************************************/
  125.  
  126. int CALLING rfClose(rfHandle file);
  127.  
  128.  
  129.  
  130.  
  131. /****************************************************************************\
  132. *
  133. * Function:     int rfGetSize(rfHandle file, long *fileSize);
  134. *
  135. * Description:  Get the size of a file
  136. *
  137. * Input:        rfHandle file           handle of an open file
  138. *               ulong *fileSize         pointer to file size
  139. *
  140. * Returns:      MIDAS error code.
  141. *               File size is stored in *fileSize.
  142. *
  143. \****************************************************************************/
  144.  
  145. int CALLING rfGetSize(rfHandle file, long *fileSize);
  146.  
  147.  
  148.  
  149.  
  150. /****************************************************************************\
  151. *
  152. * Function:     int rfRead(rfHandle file, void *buffer, ulong numBytes);
  153. *
  154. * Description:  Reads binary data from a file
  155. *
  156. * Input:        rfHandle file           file handle
  157. *               void *buffer            reading buffer
  158. *               ulong numBytes          number of bytes to read
  159. *
  160. * Returns:      MIDAS error code.
  161. *               Read data is stored in *buffer, which must be large enough
  162. *               for it.
  163. *
  164. \****************************************************************************/
  165.  
  166. int CALLING rfRead(rfHandle file, void *buffer, ulong numBytes);
  167.  
  168.  
  169.  
  170.  
  171. /****************************************************************************\
  172. *
  173. * Function:     int rfWrite(rfHandle file, void *buffer, ulong numBytes);
  174. *
  175. * Description:  Writes binary data to a file
  176. *
  177. * Input:        rfHandle file           file handle
  178. *               void *buffer            pointer to data to be written
  179. *               ulong numBytes          number of bytes to write
  180. *
  181. * Returns:      MIDAS error code
  182. *
  183. \****************************************************************************/
  184.  
  185. int CALLING rfWrite(rfHandle file, void *buffer, ulong numBytes);
  186.  
  187.  
  188.  
  189.  
  190. /****************************************************************************\
  191. *
  192. * Function:     int rfSeek(rfHandle file, long newPosition, int seekMode);
  193. *
  194. * Description:  Seeks to a new position in file. Subsequent reads and writes
  195. *               go to the new position.
  196. *
  197. * Input:        rfHandle file           file handle
  198. *               long newPosition        new file position
  199. *               int seekMode            file seek mode, see enum rfSeekMode
  200. *
  201. * Returns:      MIDAS error code
  202. *
  203. \****************************************************************************/
  204.  
  205. int CALLING rfSeek(rfHandle file, long newPosition, int seekMode);
  206.  
  207.  
  208.  
  209.  
  210. /****************************************************************************\
  211. *
  212. * Function:     int rfGetPosition(rfHandle file, long *position);
  213. *
  214. * Description:  Reads the current position in a file
  215. *
  216. * Input:        rfHandle file           file handle
  217. *               long *position          pointer to file position
  218. *
  219. * Returns:      MIDAS error code.
  220. *               Current file position is stored in *position.
  221. *
  222. \****************************************************************************/
  223.  
  224. int CALLING rfGetPosition(rfHandle file, long *position);
  225.  
  226.  
  227.  
  228.  
  229. /****************************************************************************\
  230. *
  231. * Function:     int rfFileExists(char *fileName, int *exists);
  232. *
  233. * Description:  Checks if a file exists or not
  234. *
  235. * Input:        char *fileName          file name, ASCIIZ
  236. *               int *exists             pointer to file exists status
  237. *
  238. * Returns:      MIDAS error code.
  239. *               *exists contains 1 if file exists, 0 if not.
  240. *
  241. \****************************************************************************/
  242.  
  243. int CALLING rfFileExists(char *fileName, int *exists);
  244.  
  245.  
  246.  
  247. #ifdef __cplusplus
  248. }
  249. #endif
  250.  
  251.  
  252.  
  253. /****************************************************************************\
  254. *       enum rfFunctIDs
  255. *       ---------------
  256. * Description:  ID numbers for raw file I/O functions
  257. \****************************************************************************/
  258.  
  259. enum rfFunctIDs
  260. {
  261.     ID_rfOpen = ID_rf,
  262.     ID_rfClose,
  263.     ID_rfGetSize,
  264.     ID_rfRead,
  265.     ID_rfWrite,
  266.     ID_rfSeek,
  267.     ID_rfGetPosition,
  268.     ID_rfFileExists
  269. };
  270.  
  271.  
  272. #endif
  273.  
  274.  
  275. /*
  276.  * $Log: rawfile.h,v $
  277.  * Revision 1.3  1997/01/16 18:41:59  pekangas
  278.  * Changed copyright messages to Housemarque
  279.  *
  280.  * Revision 1.2  1996/08/13 20:48:13  pekangas
  281.  * Changed for Win32 raw file I/O (rawfile.c)
  282.  *
  283.  * Revision 1.1  1996/05/22 20:49:33  pekangas
  284.  * Initial revision
  285.  *
  286. */